3a9c2824a40c566ebef4e5d3aba37ee7e56703ab,domino-jna/src/main/java/com/mindoo/domino/jna/NotesCollection.java,NotesCollection,getAllEntriesByKey,#EnumSet#EnumSet#ViewLookupCallback#Object#,1099

Before Change


				}
			}
			
			callback.lookupDone(result);
			return result;
		}
	}

After Change


					for (NotesViewEntryData currEntryData : entries) {
						Action action = callback.entryRead(result, currEntryData);
						if (action==Action.Stop) {
							result = callback.lookupDone(result);
							return result;
						}
					}
					entriesToSkipOnFirstLoopRun = entries.size();
					
					if (!data.hasMoreToDo()) {
						//we are done
						result = callback.lookupDone(result);
						return result;
					}

					//compute what we have left
					int entriesReadOnFirstLookup = entries.size();
					remainingEntries = numEntriesFound - entriesReadOnFirstLookup;
					firstMatchPosStr = data.getPosition();
				}
				else {
					//workaround for a bug where the method NIFFindByKeyExtended2 returns -1 as numEntriesFound
					//and no buffer data
					//
					//fallback to classic lookup until this is fixed/commented by IBM dev:
					FindResult findResult = findByKey(findFlags, keys);
					remainingEntries = findResult.getEntriesFound();
					if (remainingEntries==0) {
						return result;
					}
					firstMatchPosStr = findResult.getPosition();
				}
			}
			else {
				//first find the start position to read data
				FindResult findResult = findByKey(findFlags, keys);
				remainingEntries = findResult.getEntriesFound();
				if (remainingEntries==0) {
					return result;
				}
				firstMatchPosStr = findResult.getPosition();
			}

			if (!canFindExactNumberOfMatches(findFlags)) {
				Direction currSortDirection = getCurrentSortDirection();
				if (currSortDirection!=null) {
					//handle special case for inquality search where column sort order matches the find flag,
					//so we can read all view entries after findResult.getPosition()
					
					if (currSortDirection==Direction.Ascending && findFlags.contains(Find.GREATER_THAN)) {
						//read all entries after findResult.getPosition()
						remainingEntries = Integer.MAX_VALUE;
					}
					else if (currSortDirection==Direction.Descending && findFlags.contains(Find.LESS_THAN)) {
						//read all entries after findResult.getPosition()
						remainingEntries = Integer.MAX_VALUE;
					}
				}
			}

			if (firstMatchPosStr!=null) {
				//position of the first match; we skip (entries.size()) to read the remaining entries
				boolean isFirstLookup = true;
				
				NotesCollectionPosition lookupPos = NotesCollectionPosition.toPosition(firstMatchPosStr);
				
				boolean viewModified = false;
				
				while (remainingEntries>0) {
					//on first lookup, start at "posStr" and skip the amount of already read entries
					data = readEntries(lookupPos, EnumSet.of(Navigate.NEXT_NONCATEGORY), isFirstLookup ? entriesToSkipOnFirstLoopRun : 1, EnumSet.of(Navigate.NEXT_NONCATEGORY), remainingEntries, returnMask, columnsToDecode);
					
					if (isFirstLookup || isAutoUpdate()) {
						//for the first lookup, make sure we start at the right position
						if (data.hasAnyNonDataConflicts()) {
							//set viewModified to true and leave the inner loop; we will refresh the view and restart the lookup
							viewModified=true;
							break;
						}
					}
					isFirstLookup=false;
					
					List<NotesViewEntryData> entries = data.getEntries();
					if (entries.isEmpty()) {
						//looks like we don't have any more data in the view
						break;
					}
					
					for (NotesViewEntryData currEntryData : entries) {
						Action action = callback.entryRead(result, currEntryData);
						if (action==Action.Stop) {
							result = callback.lookupDone(result);
							return result;
						}
					}
					remainingEntries = remainingEntries - entries.size();
				}
				
				if (viewModified) {
					//refresh view and redo the whole lookup
					callback.viewIndexChangeDetected();
					update();
					continue;
				}
			}
			
			result = callback.lookupDone(result);
			return result;
		}
	}